Android Apprentice by By Darryl Bayliss & By Namrata Bandekar & By Tom Blankenship & By Fuad Kamal

Android Apprentice by By Darryl Bayliss & By Namrata Bandekar & By Tom Blankenship & By Fuad Kamal

Author:By Darryl Bayliss & By Namrata Bandekar & By Tom Blankenship & By Fuad Kamal
Language: eng
Format: epub
Publisher: Ray Wenderlich


Generate a unique filename

First, you need to create a helper method to generate a unique image filename.

Open ImageUtils.kt and add the following method:

@Throws(IOException::class) fun createUniqueImageFile(context: Context): File { val timeStamp = SimpleDateFormat("yyyyMMddHHmmss").format(Date()) val filename = "PlaceBook_" + timeStamp + "_" val filesDir = context.getExternalFilesDir( Environment.DIRECTORY_PICTURES) return File.createTempFile(filename, ".jpg", filesDir) }

Note: Make sure to use import java.text.SimpleDateFormat for SimpleDateFormat and jave.util.Date for Date.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.